//
//  FindPasswordViewController.m
//  homeland
//
//  Created by Alawn on 14-1-19.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "FindPasswordViewController.h"
#import "UserInfoService.h"
#import "ModifyPasswordViewController.h"
@interface FindPasswordViewController ()

@end

@implementation FindPasswordViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"找回密码";
    self.navigationItem.leftBarButtonItem = autoavBackButton(self, @selector(backMethod));

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
///下一步--找回密码
- (IBAction)nextButtonAction:(id)sender
{
    NSString *phoneNum = self.phoneField.text;
    if (!phoneNum || phoneNum.length == 0) {
        [self showAlert:@"手机号不能为空！"];
        return;
    }
    [UserInfoService getUserInfoService].delegate = self;
    [[UserInfoService getUserInfoService]checkUsrMobile:phoneNum];
    [self startLoadingViewWithText:@"正在检验"];
}
#pragma mark - User Service Delegate
-(void)loadUserInfoFinished:(id)result
{
    [self stopLoadingView];
//    [self showAlert:@"修改成功"];
    ModifyPasswordViewController *modifyVC = [[ModifyPasswordViewController alloc]initWithNibName:@"ModifyPasswordViewController" bundle:nil];
    [self.navigationController pushViewController:modifyVC animated:YES];
}

-(void)loadUserInfoFaild:(NSString *)msg
{
    [self stopLoadingView];
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"错误" message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}
-(void)showAlert:(NSString *)msg
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}

@end
